feat: add batch inference API to llama stack inference#1945
Merged
Conversation
ehhuang
approved these changes
Apr 11, 2025
Contributor
ehhuang
left a comment
There was a problem hiding this comment.
How much is the speed up? Just curious.
llama_stack/providers/inline/inference/meta_reference/inference.py
Outdated
Show resolved
Hide resolved
Contributor
Author
I will calculate some aggregate toks/sec values by running a bunch of examples (from evals) linearly vs batch. |
Contributor
Author
|
Corresponding llama-stack-client changes: llamastack/llama-stack-client-python#220 |
ashwinb
added a commit
to llamastack/llama-stack-client-python
that referenced
this pull request
Apr 12, 2025
Contributor
Author
|
@ehhuang Here are some numbers for various batch sizes running for 100 samples of the BFCL benchmark: llama-4-scout
llama-3.3-70b
My conclusion: this batch inference implementation is far from "effective" in terms of accelerating inference substantially. However, it is a good first step. Most of the work in the PR is infrastructure. Furthermore, we can now connect to vLLM's (inline) batch APIs when needed. |
MichaelClifford
pushed a commit
to MichaelClifford/llama-stack
that referenced
this pull request
Apr 14, 2025
# What does this PR do? This PR adds two methods to the Inference API: - `batch_completion` - `batch_chat_completion` The motivation is for evaluations targeting a local inference engine (like meta-reference or vllm) where batch APIs provide for a substantial amount of acceleration. Why did I not add this to `Api.batch_inference` though? That just resulted in a _lot_ more book-keeping given the structure of Llama Stack. Had I done that, I would have needed to create a notion of a "batch model" resource, setup routing based on that, etc. This does not sound ideal. So what's the future of the batch inference API? I am not sure. Maybe we can keep it for true _asynchronous_ execution. So you can submit requests, and it can return a Job instance, etc. ## Test Plan Run meta-reference-gpu using: ```bash export INFERENCE_MODEL=meta-llama/Llama-4-Scout-17B-16E-Instruct export INFERENCE_CHECKPOINT_DIR=../checkpoints/Llama-4-Scout-17B-16E-Instruct-20250331210000 export MODEL_PARALLEL_SIZE=4 export MAX_BATCH_SIZE=32 export MAX_SEQ_LEN=6144 LLAMA_MODELS_DEBUG=1 llama stack run meta-reference-gpu ``` Then run the batch inference test case.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR adds two methods to the Inference API:
batch_completionbatch_chat_completionThe motivation is for evaluations targeting a local inference engine (like meta-reference or vllm) where batch APIs provide for a substantial amount of acceleration.
Why did I not add this to
Api.batch_inferencethough? That just resulted in a lot more book-keeping given the structure of Llama Stack. Had I done that, I would have needed to create a notion of a "batch model" resource, setup routing based on that, etc. This does not sound ideal.So what's the future of the batch inference API? I am not sure. Maybe we can keep it for true asynchronous execution. So you can submit requests, and it can return a Job instance, etc.
Test Plan
Run meta-reference-gpu using:
Then run the batch inference test case.